$(function() { 

	//评论验证
	$("#commentform").validity(function() { 
		$("#author").require('姓名是必须的！'); 
		$("#email").require('电子邮件是必须的！').match('email','电子邮件格式不正确！');
		$("#url").match('url','站点格式不正确！');
		$("#comment").require('请输入留言内容！');
	}); 
	//搜索验证
	$("#searchform").validity(function() { 
		$("#search").require('搜索条件是必须的！'); 
	}); 

	//提交评论ajax设置
	var comment_options = { 
		dataType: 'json',
		clearForm: true,
        success: comment_success_function		
    }; 

	//提交成功后
	function comment_success_function(data)
	{
		if(data.status == 0)
		{
			art.dialog({
				title: '提示',
				icon: 'error',
				content: data.message,
				ok: true
			});
		}
		else if(data.status == 1)
		{
			art.dialog({
				time: 3,
				title: '3秒后自动关闭',
				icon: 'warning',
				content: data.message,
				ok: true
			});
		}
		else if(data.status == 2)
		{
			art.dialog({
				time: 2,
				title: '2秒后自动跳转到您的评论',
				icon: 'succeed',
				content: data.message,
				ok: true,
				close: function () {
					window.location.href = data.url;
				}
			});
		}
	}


	//提交评论
	$('#commentform').ajaxForm(comment_options); 
});